package com.ymatou.iapi.godmch.testcase;

import java.util.HashMap;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.getMchShareBuyerPicBean;
import com.ymatou.iapi.godmch.parameter.setShareTypeBean;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.getMchShareBuyerPicCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.sqlwapper.godmch.mch_infoWapper;
/**
*获取店铺买家端分享图片
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getMchShareBuyerPic{
	private static getMchShareBuyerPicBean bean;
	private static getMchShareBuyerPicCall call;
	private static mch_infoWapper mchinfoWapper=new mch_infoWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取店铺买家端分享图片");
	}

	@Before
	public void caseUp() {
		bean=new getMchShareBuyerPicBean();
		call=new getMchShareBuyerPicCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_001() {
		Logger.start(true,"获取店铺买家端分享图片--验证公版小程序");
		try {
			UserCreateBean usercreateBean=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean);
			//渠道
			createmchBean createBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createBean);
			
			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(createBean.getMchId());
			setShareTypeBean.setPayMode(1);//微信HipoPay支付通道:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通 4:飞界国际贸易 5：自有支付
			setShareTypeBean.setMchShareType(1);// 分享方式1：小程序 2：H5// 3：独立小程序 4：独立h5// 5：继承版小程序
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);
			
			bean.setMchId(createBean.getMchId());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true, call.getPicUrl().length()>0, "验证PicUrl");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_002() {
		Logger.start(true,"获取店铺买家端分享图片--验证公版H5");
		try {
			UserCreateBean usercreateBean=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean);
			//渠道
			createmchBean createBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createBean);
			
			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(createBean.getMchId());
			setShareTypeBean.setMchShareType(2);// 分享方式1：小程序 2：H5// 3：独立小程序 4：独立h5// 5：继承版小程序
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);
			
			bean.setMchId(createBean.getMchId());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true, call.getPicUrl().length()>0, "验证PicUrl");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_002_1() {
		Logger.start(true,"获取店铺买家端分享图片--验证公版独立小程序");
		try {
			UserCreateBean usercreateBean=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean);
			//渠道
			createmchBean createBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createBean);
			
			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(createBean.getMchId());
			setShareTypeBean.setMchShareType(3);// 分享方式1：小程序 2：H5// 3：独立小程序 4：独立h5// 5：继承版小程序
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);
			
			bean.setMchId(createBean.getMchId());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true, call.getPicUrl().length()>0, "验证PicUrl");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_002_2() {
		Logger.start(true,"获取店铺买家端分享图片--验证公版独立h5");
		try {
			UserCreateBean usercreateBean=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean);
			//渠道
			createmchBean createBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createBean);
			
			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(createBean.getMchId());
			setShareTypeBean.setMchShareType(4);// 分享方式1：小程序 2：H5// 3：独立小程序 4：独立h5// 5：继承版小程序
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);
			
			bean.setMchId(createBean.getMchId());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true, call.getPicUrl().length()>0, "验证PicUrl");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_005() {
		Logger.start(true,"获取店铺买家端分享图片-验证独立云商户小程序-token不存在");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchBean.setMchShareType(1);// 店铺买家端呈现形式//1：小程序 2：H5 3：独立小程序 4：独立h5 5：继承版小程序
			createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
			
			bean.setMchId(createIndepMchCall.getmchId());
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("5000", call.getStatusCode1(), "验证status");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getMchShareBuyerPic_005_1() {
		Logger.start(true,"获取店铺买家端分享图片-验证独立云商户小程序-token存在");
		try {
//			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
//			createIndepMchBean.setMchShareType(1);// 店铺买家端呈现形式//1：小程序 2：H5 3：独立小程序 4：独立h5 5：继承版小程序
//			//www.worlddada.com
//			createIndepMchBean.setAppDomain("www.worlddada.com");
//			
//			createIndepMchBean.setWxAppId("wx6a71c435b353f767");
//			createIndepMchBean.setWxSecretApp("2c66e198413e42d383a5c584f84ff15b");
//		
//			createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
//			
//			bean.setMchId(createIndepMchCall.getmchId());
			bean.setMchId(500849411);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_006() {
		Logger.start(true,"获取店铺买家端分享图片-验证独立云商H5");
		try {
			createIndepMchBean createIndepMchBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchBean.setMchShareType(2);// 店铺买家端呈现形式//1：小程序 2：H5 3：独立小程序 4：独立h5 5：继承版小程序
		
			createIndepMchCall createIndepMchCall=GodmchManageCallService.CreateIndepMchCall(createIndepMchBean);
			
			bean.setMchId(createIndepMchCall.getmchId());

			call.setData(bean);
			call.callService();				
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true, call.getPicUrl().length()>0, "验证PicUrl");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_getMchShareBuyerPic_005_3() {
		Logger.start(true,"获取店铺买家端分享图片-验证独立云商户独立小程序-token存在");
		try {

			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(500849411);
			setShareTypeBean.setPayMode(1);//微信HipoPay支付通道:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通 4:飞界国际贸易 5：自有支付
			setShareTypeBean.setMchShareType(3);// 分享方式1：小程序 2：H5// 3：独立小程序 4：独立h5// 5：继承版小程序
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);
			
			bean.setMchId(500849411);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_007() {
		Logger.start(true,"获取店铺买家端分享图片-验证mchId不存在");
		try {
			
			bean.setMchId(111111111);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("5000", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchShareBuyerPic_008() {
		Logger.start(true,"获取店铺买家端分享图片-验证mchId为空");
		try {
			
			//bean.setMchId(111111111);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}